package com.lz.ovuola.util.auth;

import java.time.Instant;

import com.lz.ovuola.util.codec.EncryptionUtils;
import com.lz.ovuola.util.date.DateUtils;

/**
 * token工具类
 * 
 * @author fz
 *
 */
public abstract class TokenGenerateUtils {
	private static final int EXPIRATION = 30;// 过期时间/星期

	/**
	 * 生成唯一token
	 * 
	 * @param userId
	 *            用户id
	 * @param user
	 *            手机号或第三方id
	 * @return
	 */
	public static final String generateToken(int userId, String user) {
		return EncryptionUtils.md5(userId + user + Instant.now());
	}

	/**
	 * 过期日期
	 * 
	 * @return
	 */
	public static final Long generateEx() {
		return DateUtils.getAfterSeveralUnitsReturn(EXPIRATION);
	}

	public static int getExpiration() {
		return EXPIRATION;
	}

}
